<template>
  <ul class="footerBar">
    <li
    v-for="(route,index) in tabRoutes" 
    :key="route.path" 
    @click="jump(route.path,index)"
    :class="{ active: currentIndex === index }">
        <i class="iconfont" v-html="route.meta.icon"></i>
        <span>{{ route.meta.title }}</span>
    </li>
  </ul>
</template>

<script>
  import routes from '@/router/routes'
  export default {
    name: 'TabBar',
    data() {
      return {
        currentIndex: 0
      }
    },
    computed: {
      tabRoutes() {
        return routes.filter(route => route.meta?.isTabBar)
      }
    },
    methods: {
      jump (path,index) {
        this.$router.push(path)
        this.currentIndex = index
      }
    }
  }
</script>

<style lang="less" scoped>
@font-face {
  font-family: 'iconfont';  /* project id 2423474 */
  src: url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.eot');
  src: url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.eot?#iefix') format('embedded-opentype'),
  url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.woff2') format('woff2'),
  url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.woff') format('woff'),
  url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.ttf') format('truetype'),
  url('//at.alicdn.com/t/font_2423474_s9m9q0r83d.svg#iconfont') format('svg');
}
.iconfont{
    font-family:"iconfont" !important;
    font-size:16px;font-style:normal;
    -webkit-font-smoothing: antialiased;
    -webkit-text-stroke-width: 0.2px;
    -moz-osx-font-smoothing: grayscale;}


.footerBar {
    display: flex;
    border-top: 1px solid #eaeaea;

    li {
        flex: 1;
        height: 64px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        align-items: center;

        i {
        font-size: 32px;
        }

        &.active {
        color: #d81e06;
        font-weight: 700;
        }
    }
}
</style>